﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MachineBuildingSystem
{
    public partial class BackConcreteBaseInfo : UserControl
    {
        public BackConcreteBaseInfo()
        {
            InitializeComponent();
        }

        private void rgpSignStatus_SelectedIndexChanged(object sender, EventArgs e)
        {
            //客户全部签收包括1、2、3
            if (rgpSignStatus.SelectedIndex == 0)
            {
                SetProcessStatusEnable(true);
                rgpProcessStatus.SelectedIndex = 0;
            }
            //客户部分签收包括4、5、6
            else
            {
                SetProcessStatusEnable(false);
                rgpProcessStatus.SelectedIndex = 3;
            }
        }

        private void SetProcessStatusEnable(bool isEnable)
        {
            rgpProcessStatus.Properties.Items[0].Enabled = isEnable;
            rgpProcessStatus.Properties.Items[1].Enabled = isEnable;
            rgpProcessStatus.Properties.Items[2].Enabled = isEnable;
            rgpProcessStatus.Properties.Items[3].Enabled = !isEnable;
            rgpProcessStatus.Properties.Items[4].Enabled = !isEnable;
            rgpProcessStatus.Properties.Items[5].Enabled = !isEnable;
        }

        //获取退砼基本信息
        public void GetBackConcreteBaseInfo(ref BackConcreteInfo backConcreteInfo)
        {
            backConcreteInfo.Number = decimal.Parse(this.spinEditNumber.EditValue.ToString());
            backConcreteInfo.Explain = this.memoEditRemark.Text.Trim();
            backConcreteInfo.State = this.rgpProcessStatus.SelectedIndex;
        }

        private string m_ProjectName = "";
        public void SetProjectName(string projectName)
        {
            m_ProjectName = projectName;
            if (rgpProcessStatus.SelectedIndex == 1 || rgpProcessStatus.SelectedIndex == 4)
                this.txtProduceName.Text = projectName;
            else
                this.txtProduceName.Text = "";
        }

        private void rgpProcessStatus_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (rgpProcessStatus.SelectedIndex == 1 || rgpProcessStatus.SelectedIndex == 4)
                this.txtProduceName.Text = m_ProjectName;
            else
                this.txtProduceName.Text = "";
        }

        private void spinEditNumber_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
        {
            if (e.NewValue != null && e.NewValue.ToString().StartsWith("-"))
            {
                e.Cancel = true;
            }
        }
    }

    public enum BackConcreteStatusEnum : int
    {
        //废剩料
        WasteResidue = 0,
        //回收料，直接发其他工地
        Recovery =1,
        //回收料，调料发其他工地
        RecoveryAllocate = 2,
        //报废料
        NewspaperScrap = 3,
        //退砼，直接发其他工地
        BackConcrete = 4,
        //退砼，调料发其他工地
        BackConcreteAllocate = 5
    }

}
